<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Hardware Abstraction Layer (HAL)</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.cypress.com/"><img alt="Logo" src="logo.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Hardware Abstraction Layer (HAL)</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('group__group__hal__usb__dev.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#groups">API Reference</a>  </div>
  <div class="headertitle"><div class="title">USB Device<div class="ingroups"><a class="el" href="group__group__hal.html">HAL Drivers</a></div></div></div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">General Description</h2>
<p >High level interface for interacting with the USB Device. </p>
<p >This block supports one control endpoint (EP0) and one or more data endpoints. See the device datasheet for the number of data endpoints supported.</p>
<p >Four transfer types are supported (see <a class="el" href="group__group__hal__usb__dev__endpoint.html#gaa050c9639ab34294735f8ef572b9e417">cyhal_usb_dev_ep_type_t</a>):</p><ul>
<li>Bulk</li>
<li>Interrupt</li>
<li>Isochronous</li>
<li>Control</li>
</ul>
<h1><a class="anchor" id="section_usb_dev_features"></a>
Features</h1>
<ul>
<li>Complies with USB specification 2.0</li>
<li>Supports full-speed peripheral device operation with a signaling bit rate of 12 Mbps.</li>
<li>Configurable D+ AND D- pins using <a class="el" href="group__group__hal__types__implementation.html#ga37579d500a1d05905c8f2bea4e907f99">cyhal_gpio_t</a></li>
<li>Configurable Interrupt and Callback assignment on USB events like SOF, Bus Reset, EP0 Setup and EP0 transaction.</li>
<li>Configurable USB device address.</li>
<li>Configurable USB Endpoints (except for Endpoint 0)</li>
</ul>
<h1><a class="anchor" id="section_usb_dev_quickstart"></a>
Quick Start</h1>
<p ><a class="el" href="group__group__hal__usb__dev__common.html#ga3fada34f2e7c54d8fae5def861f41083">cyhal_usb_dev_init</a> can be used for initialization of USB by providing the USBDP and USBDM pins. See <a class="el" href="group__group__hal__usb__dev.html#subsection_usb_dev_snippet_1">Snippet 1: USB Device Initialization</a> for the initialization code snippet.</p>
<h1><a class="anchor" id="section_usb_dev_snippets"></a>
Code snippets</h1>
<h2><a class="anchor" id="subsection_usb_dev_snippet_1"></a>
Snippet 1: USB Device Initialization</h2>
<p >The following section initializes the USB Device and assigns the USBDM and USBDP pins using <a class="el" href="group__group__hal__usb__dev__common.html#ga3fada34f2e7c54d8fae5def861f41083">cyhal_usb_dev_init</a>. The clock parameter <b>clk</b> is optional and need not be provided (NULL), to generate and use an available clock resource with a default frequency. The device can be made physically visible to the USB Host by using <a class="el" href="group__group__hal__usb__dev__common.html#ga58083386748f9295037d7567330b9677">cyhal_usb_dev_connect</a></p>
<div class="fragment"><div class="line">    <a class="code hl_struct" href="group__group__hal__impl__hw__types.html#structcyhal__usb__dev__t">cyhal_usb_dev_t</a> usb_dev_obj;</div>
<div class="line">    <a class="code hl_typedef" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>       rslt;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Initialize USB, assign the USBDP and USBDM pins and assign a new clock</span></div>
<div class="line">    rslt = <a class="code hl_function" href="group__group__hal__usb__dev__common.html#ga3fada34f2e7c54d8fae5def861f41083">cyhal_usb_dev_init</a>(&amp;usb_dev_obj, <a class="code hl_enumvalue" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble__usb.html#ggadb1b30ad8667ff98ff7c39046c4d0741a91f4d44fb984bb1c20f9a34af8015642">USBDP</a>, <a class="code hl_enumvalue" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble__usb.html#ggadb1b30ad8667ff98ff7c39046c4d0741a4ce5d83730a8b57610cdffe18cd54eff">USBDM</a>, NULL);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Application code to register callback functions, enable events, add endpoints, etc.</span></div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Make the USB device physically visible to USB host</span></div>
<div class="line">    <a class="code hl_function" href="group__group__hal__usb__dev__common.html#ga58083386748f9295037d7567330b9677">cyhal_usb_dev_connect</a>(&amp;usb_dev_obj);</div>
<div class="line"> </div>
<div class="ttc" id="agroup__group__hal__impl__hw__types_html_structcyhal__usb__dev__t"><div class="ttname"><a href="group__group__hal__impl__hw__types.html#structcyhal__usb__dev__t">cyhal_usb_dev_t</a></div><div class="ttdoc">USB Device object.</div><div class="ttdef"><b>Definition:</b> cyhal_hw_types.h:1574</div></div>
<div class="ttc" id="agroup__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble__usb_html_ggadb1b30ad8667ff98ff7c39046c4d0741a4ce5d83730a8b57610cdffe18cd54eff"><div class="ttname"><a href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble__usb.html#ggadb1b30ad8667ff98ff7c39046c4d0741a4ce5d83730a8b57610cdffe18cd54eff">USBDM</a></div><div class="ttdeci">@ USBDM</div><div class="ttdoc">Port 14 Pin 1.</div><div class="ttdef"><b>Definition:</b> cyhal_psoc6_01_104_m_csp_ble_usb.h:137</div></div>
<div class="ttc" id="agroup__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble__usb_html_ggadb1b30ad8667ff98ff7c39046c4d0741a91f4d44fb984bb1c20f9a34af8015642"><div class="ttname"><a href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble__usb.html#ggadb1b30ad8667ff98ff7c39046c4d0741a91f4d44fb984bb1c20f9a34af8015642">USBDP</a></div><div class="ttdeci">@ USBDP</div><div class="ttdoc">Port 14 Pin 0.</div><div class="ttdef"><b>Definition:</b> cyhal_psoc6_01_104_m_csp_ble_usb.h:135</div></div>
<div class="ttc" id="agroup__group__hal__usb__dev__common_html_ga3fada34f2e7c54d8fae5def861f41083"><div class="ttname"><a href="group__group__hal__usb__dev__common.html#ga3fada34f2e7c54d8fae5def861f41083">cyhal_usb_dev_init</a></div><div class="ttdeci">cy_rslt_t cyhal_usb_dev_init(cyhal_usb_dev_t *obj, cyhal_gpio_t dp, cyhal_gpio_t dm, const cyhal_clock_t *clk)</div><div class="ttdoc">Initialize the USB instance.</div></div>
<div class="ttc" id="agroup__group__hal__usb__dev__common_html_ga58083386748f9295037d7567330b9677"><div class="ttname"><a href="group__group__hal__usb__dev__common.html#ga58083386748f9295037d7567330b9677">cyhal_usb_dev_connect</a></div><div class="ttdeci">void cyhal_usb_dev_connect(cyhal_usb_dev_t *obj)</div><div class="ttdoc">Make the USB device visible to the USB host.</div></div>
<div class="ttc" id="agroup__group__result_html_gaca79700fcc701534ce61778a9bcf57d1"><div class="ttname"><a href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a></div><div class="ttdeci">uint32_t cy_rslt_t</div><div class="ttdoc">Provides the result of an operation as a structured bitfield.</div><div class="ttdef"><b>Definition:</b> cy_result.h:438</div></div>
</div><!-- fragment --><h2><a class="anchor" id="subsection_usb_dev_snippet_2"></a>
Snippet 2: Handling USB Event Completion</h2>
<p >USB events (see <a class="el" href="group__group__hal__usb__dev__common.html#gab0df7903f398f360d71e8beb78ead49b">cyhal_usb_dev_event_t</a>) like Bus Reset, EP0 transaction, EP0 Setup can be mapped to an interrupt and assigned a callback function. The callback function needs to be first registered using <a class="el" href="group__group__hal__usb__dev__common.html#ga12a92ec4893a4eb384ecf1260ca9ea42">cyhal_usb_dev_register_event_callback</a>. Use different callback functions to handle events individually.</p>
<div class="fragment"><div class="line"> </div>
<div class="line"><a class="code hl_struct" href="group__group__hal__impl__hw__types.html#structcyhal__usb__dev__t">cyhal_usb_dev_t</a> usb_dev_obj;</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> usb_dev_event_handler()</div>
<div class="line">{</div>
<div class="line">    <span class="comment">// Handle USB Events here</span></div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> snippet_cyhal_usb_dev_event()</div>
<div class="line">{</div>
<div class="line">    <span class="comment">// Initialize the USB as done in Snippet 1</span></div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Register callback handler for USB events EP0_OUT, EP0_IN, Bus Reset, EP0_SETUP</span></div>
<div class="line">    <a class="code hl_function" href="group__group__hal__usb__dev__common.html#ga12a92ec4893a4eb384ecf1260ca9ea42">cyhal_usb_dev_register_event_callback</a>(&amp;usb_dev_obj,</div>
<div class="line">                                          (<a class="code hl_enumeration" href="group__group__hal__usb__dev__common.html#gab0df7903f398f360d71e8beb78ead49b">cyhal_usb_dev_event_t</a>)(<a class="code hl_enumvalue" href="group__group__hal__usb__dev__common.html#ggab0df7903f398f360d71e8beb78ead49bac715be16269b7dfb4294a8fb13b649ab">CYHAL_USB_DEV_EVENT_EP0_OUT</a> |</div>
<div class="line">                                                                  <a class="code hl_enumvalue" href="group__group__hal__usb__dev__common.html#ggab0df7903f398f360d71e8beb78ead49baa1d503404e8c909e63c329dc4f74684b">CYHAL_USB_DEV_EVENT_EP0_SETUP</a> |</div>
<div class="line">                                                                  <a class="code hl_enumvalue" href="group__group__hal__usb__dev__common.html#ggab0df7903f398f360d71e8beb78ead49ba2dfe95c0891c7c37eda0c5e707e45229">CYHAL_USB_DEV_EVENT_EP0_IN</a> |</div>
<div class="line">                                                                  <a class="code hl_enumvalue" href="group__group__hal__usb__dev__common.html#ggab0df7903f398f360d71e8beb78ead49ba519b2fbe16ee25f7b19e30e1055a6532">CYHAL_USB_DEV_EVENT_BUS_RESET</a>),</div>
<div class="line">                                          usb_dev_event_handler);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="ttc" id="agroup__group__hal__usb__dev__common_html_ga12a92ec4893a4eb384ecf1260ca9ea42"><div class="ttname"><a href="group__group__hal__usb__dev__common.html#ga12a92ec4893a4eb384ecf1260ca9ea42">cyhal_usb_dev_register_event_callback</a></div><div class="ttdeci">void cyhal_usb_dev_register_event_callback(cyhal_usb_dev_t *obj, cyhal_usb_dev_event_t event, cyhal_usb_dev_event_callback_t callback)</div><div class="ttdoc">The USB Device event complete callback handler registration.</div></div>
<div class="ttc" id="agroup__group__hal__usb__dev__common_html_gab0df7903f398f360d71e8beb78ead49b"><div class="ttname"><a href="group__group__hal__usb__dev__common.html#gab0df7903f398f360d71e8beb78ead49b">cyhal_usb_dev_event_t</a></div><div class="ttdeci">cyhal_usb_dev_event_t</div><div class="ttdoc">Service Callback Events.</div><div class="ttdef"><b>Definition:</b> cyhal_usb_dev.h:157</div></div>
<div class="ttc" id="agroup__group__hal__usb__dev__common_html_ggab0df7903f398f360d71e8beb78ead49ba2dfe95c0891c7c37eda0c5e707e45229"><div class="ttname"><a href="group__group__hal__usb__dev__common.html#ggab0df7903f398f360d71e8beb78ead49ba2dfe95c0891c7c37eda0c5e707e45229">CYHAL_USB_DEV_EVENT_EP0_IN</a></div><div class="ttdeci">@ CYHAL_USB_DEV_EVENT_EP0_IN</div><div class="ttdoc">Callback hooked to endpoint 0 IN packet interrupt.</div><div class="ttdef"><b>Definition:</b> cyhal_usb_dev.h:160</div></div>
<div class="ttc" id="agroup__group__hal__usb__dev__common_html_ggab0df7903f398f360d71e8beb78ead49ba519b2fbe16ee25f7b19e30e1055a6532"><div class="ttname"><a href="group__group__hal__usb__dev__common.html#ggab0df7903f398f360d71e8beb78ead49ba519b2fbe16ee25f7b19e30e1055a6532">CYHAL_USB_DEV_EVENT_BUS_RESET</a></div><div class="ttdeci">@ CYHAL_USB_DEV_EVENT_BUS_RESET</div><div class="ttdoc">Callback hooked to bus reset interrupt.</div><div class="ttdef"><b>Definition:</b> cyhal_usb_dev.h:158</div></div>
<div class="ttc" id="agroup__group__hal__usb__dev__common_html_ggab0df7903f398f360d71e8beb78ead49baa1d503404e8c909e63c329dc4f74684b"><div class="ttname"><a href="group__group__hal__usb__dev__common.html#ggab0df7903f398f360d71e8beb78ead49baa1d503404e8c909e63c329dc4f74684b">CYHAL_USB_DEV_EVENT_EP0_SETUP</a></div><div class="ttdeci">@ CYHAL_USB_DEV_EVENT_EP0_SETUP</div><div class="ttdoc">Callback hooked to endpoint 0 SETUP packet interrupt.</div><div class="ttdef"><b>Definition:</b> cyhal_usb_dev.h:159</div></div>
<div class="ttc" id="agroup__group__hal__usb__dev__common_html_ggab0df7903f398f360d71e8beb78ead49bac715be16269b7dfb4294a8fb13b649ab"><div class="ttname"><a href="group__group__hal__usb__dev__common.html#ggab0df7903f398f360d71e8beb78ead49bac715be16269b7dfb4294a8fb13b649ab">CYHAL_USB_DEV_EVENT_EP0_OUT</a></div><div class="ttdeci">@ CYHAL_USB_DEV_EVENT_EP0_OUT</div><div class="ttdoc">Callback hooked to endpoint 0 OUT packet interrupt.</div><div class="ttdef"><b>Definition:</b> cyhal_usb_dev.h:161</div></div>
</div><!-- fragment --><h2><a class="anchor" id="subsection_usb_dev_snippet_3"></a>
Snippet 3: Custom USB Interrupt Handler</h2>
<p >The following section illustrates how to set up the IRQ interrupt handler for USB device. Inside the handler <a class="el" href="group__group__hal__usb__dev__common.html#ga437539361016b466626e103dd72a886d">cyhal_usb_dev_process_irq</a> has been used to process the interrupts.</p>
<div class="fragment"><div class="line"> </div>
<div class="line"><a class="code hl_struct" href="group__group__hal__impl__hw__types.html#structcyhal__usb__dev__t">cyhal_usb_dev_t</a> usb_dev_obj;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Interrupt handler callback function</span></div>
<div class="line"><span class="keywordtype">void</span> usb_irq_handler()</div>
<div class="line">{</div>
<div class="line">    <span class="comment">// Calling the default USB handler</span></div>
<div class="line">    <a class="code hl_function" href="group__group__hal__usb__dev__common.html#ga437539361016b466626e103dd72a886d">cyhal_usb_dev_process_irq</a>(&amp;usb_dev_obj);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> snippet_cyhal_usb_dev_irq()</div>
<div class="line">{</div>
<div class="line">    <span class="comment">// Initialize the USB Device</span></div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Configure USB Device event enablement</span></div>
<div class="line">    <a class="code hl_function" href="group__group__hal__usb__dev__common.html#gaa1cbb4285b35e80b57a6fce5127890ce">cyhal_usb_dev_irq_enable</a>(&amp;usb_dev_obj, <span class="keyword">true</span>);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Register the callback function to handle the events</span></div>
<div class="line">    <a class="code hl_function" href="group__group__hal__usb__dev__common.html#gaa5db167ff60bc74a118823bb876bcdd6">cyhal_usb_dev_register_irq_callback</a>(&amp;usb_dev_obj, usb_irq_handler);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="ttc" id="agroup__group__hal__usb__dev__common_html_ga437539361016b466626e103dd72a886d"><div class="ttname"><a href="group__group__hal__usb__dev__common.html#ga437539361016b466626e103dd72a886d">cyhal_usb_dev_process_irq</a></div><div class="ttdeci">void cyhal_usb_dev_process_irq(cyhal_usb_dev_t *obj)</div><div class="ttdoc">Default USB Device interrupt handler.</div></div>
<div class="ttc" id="agroup__group__hal__usb__dev__common_html_gaa1cbb4285b35e80b57a6fce5127890ce"><div class="ttname"><a href="group__group__hal__usb__dev__common.html#gaa1cbb4285b35e80b57a6fce5127890ce">cyhal_usb_dev_irq_enable</a></div><div class="ttdeci">void cyhal_usb_dev_irq_enable(cyhal_usb_dev_t *obj, bool enable)</div><div class="ttdoc">Configure USB Device event enablement.</div></div>
<div class="ttc" id="agroup__group__hal__usb__dev__common_html_gaa5db167ff60bc74a118823bb876bcdd6"><div class="ttname"><a href="group__group__hal__usb__dev__common.html#gaa5db167ff60bc74a118823bb876bcdd6">cyhal_usb_dev_register_irq_callback</a></div><div class="ttdeci">cy_rslt_t cyhal_usb_dev_register_irq_callback(cyhal_usb_dev_t *obj, cyhal_usb_dev_irq_callback_t callback)</div><div class="ttdoc">Register a USB Device callback handler.</div></div>
</div><!-- fragment --><h2><a class="anchor" id="subsection_usb_dev_snippet_4"></a>
Snippet 4: Adding an Endpoint and Handling its Interrupts</h2>
<p >The following section shows how to add endpoint to the USB device and configure the endpoint using <a class="el" href="group__group__hal__usb__dev__endpoint.html#ga19afd43bcec6dc1c3a54cc3d3620bdcf">cyhal_usb_dev_endpoint_add</a>. The interrupts associated with the endpoints are handled by a callback function registered using <a class="el" href="group__group__hal__usb__dev__endpoint.html#ga128a701f82f6250a3a907f417959182e">cyhal_usb_dev_register_endpoint_callback</a>. The endpoint can also be configured using <a href="https://www.cypress.com/ModusToolboxUSBConfig">ModusToolbox™ USB Configurator</a></p>
<div class="fragment"><div class="line"><a class="code hl_typedef" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>       rslt;</div>
<div class="line"><a class="code hl_struct" href="group__group__hal__impl__hw__types.html#structcyhal__usb__dev__t">cyhal_usb_dev_t</a> usb_dev_obj;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Declare USB Endpoint address that consists of endpoint number and direction</span></div>
<div class="line"><span class="comment">// EP1 address value = 0x81 where bits 6:0 represent the endpoint number(0x01) and 7th bit represent</span></div>
<div class="line"><span class="comment">// the (IN) direction (0x10).</span></div>
<div class="line"><span class="comment">// The decimal equivalent of which is 129.</span></div>
<div class="line"><span class="comment">// This value is obtained while configuring the endpoint using Modustoolbox USB Configurator</span></div>
<div class="line"><span class="keyword">const</span> uint8_t EP1 = 129;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Declare the maximum packet size that can be sent or received</span></div>
<div class="line"><span class="keyword">const</span> uint32_t max_packet_size = 8;</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> endpoint_handler()</div>
<div class="line">{</div>
<div class="line">    <span class="comment">// Handle Endpoint related Interrupts here</span></div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> snippet_cyhal_usb_dev_endpoint()</div>
<div class="line">{</div>
<div class="line">    <span class="comment">// Initialize the USB Device here</span></div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Adding Endpoint 1 as Interrupt endpoint, with direction IN</span></div>
<div class="line">    rslt = <a class="code hl_function" href="group__group__hal__usb__dev__endpoint.html#ga19afd43bcec6dc1c3a54cc3d3620bdcf">cyhal_usb_dev_endpoint_add</a>(&amp;usb_dev_obj, <span class="keyword">true</span>, <span class="keyword">true</span>, EP1, max_packet_size,</div>
<div class="line">                                      CYHAL_USB_DEV_EP_TYPE_INT);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Register callback handler for Endpoint 1</span></div>
<div class="line">    <a class="code hl_function" href="group__group__hal__usb__dev__endpoint.html#ga128a701f82f6250a3a907f417959182e">cyhal_usb_dev_register_endpoint_callback</a>(&amp;usb_dev_obj,</div>
<div class="line">                                             (<a class="code hl_typedef" href="group__group__hal__usb__dev__common.html#ga62a268fe35f5e68f1faf9b362ee6c307">cyhal_usb_dev_ep_t</a>)EP1,</div>
<div class="line">                                             (<a class="code hl_typedef" href="group__group__hal__usb__dev__common.html#ga88241f53490fed2cce33872947c67053">cyhal_usb_dev_endpoint_callback_t</a>)endpoint_handler);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Enable added Endpoint</span></div>
<div class="line">    <a class="code hl_function" href="group__group__hal__usb__dev__common.html#ga93a43b761729183af402967f11c212ae">cyhal_usb_dev_set_configured</a>(&amp;usb_dev_obj);</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="ttc" id="agroup__group__hal__usb__dev__common_html_ga62a268fe35f5e68f1faf9b362ee6c307"><div class="ttname"><a href="group__group__hal__usb__dev__common.html#ga62a268fe35f5e68f1faf9b362ee6c307">cyhal_usb_dev_ep_t</a></div><div class="ttdeci">uint8_t cyhal_usb_dev_ep_t</div><div class="ttdoc">USB endpoint address (consists from endpoint number and direction)</div><div class="ttdef"><b>Definition:</b> cyhal_usb_dev.h:168</div></div>
<div class="ttc" id="agroup__group__hal__usb__dev__common_html_ga88241f53490fed2cce33872947c67053"><div class="ttname"><a href="group__group__hal__usb__dev__common.html#ga88241f53490fed2cce33872947c67053">cyhal_usb_dev_endpoint_callback_t</a></div><div class="ttdeci">void(* cyhal_usb_dev_endpoint_callback_t)(cyhal_usb_dev_ep_t endpoint)</div><div class="ttdoc">Callback handler for the transfer completion event for data endpoints (not applicable for endpoint 0)</div><div class="ttdef"><b>Definition:</b> cyhal_usb_dev.h:178</div></div>
<div class="ttc" id="agroup__group__hal__usb__dev__common_html_ga93a43b761729183af402967f11c212ae"><div class="ttname"><a href="group__group__hal__usb__dev__common.html#ga93a43b761729183af402967f11c212ae">cyhal_usb_dev_set_configured</a></div><div class="ttdeci">void cyhal_usb_dev_set_configured(cyhal_usb_dev_t *obj)</div><div class="ttdoc">Set this device to the configured state.</div></div>
<div class="ttc" id="agroup__group__hal__usb__dev__endpoint_html_ga128a701f82f6250a3a907f417959182e"><div class="ttname"><a href="group__group__hal__usb__dev__endpoint.html#ga128a701f82f6250a3a907f417959182e">cyhal_usb_dev_register_endpoint_callback</a></div><div class="ttdeci">void cyhal_usb_dev_register_endpoint_callback(cyhal_usb_dev_t *obj, cyhal_usb_dev_ep_t endpoint, cyhal_usb_dev_endpoint_callback_t callback)</div><div class="ttdoc">The USB Device endpoint complete callback handler registration.</div></div>
<div class="ttc" id="agroup__group__hal__usb__dev__endpoint_html_ga19afd43bcec6dc1c3a54cc3d3620bdcf"><div class="ttname"><a href="group__group__hal__usb__dev__endpoint.html#ga19afd43bcec6dc1c3a54cc3d3620bdcf">cyhal_usb_dev_endpoint_add</a></div><div class="ttdeci">cy_rslt_t cyhal_usb_dev_endpoint_add(cyhal_usb_dev_t *obj, bool alloc, bool enable, cyhal_usb_dev_ep_t endpoint, uint32_t max_packet, cyhal_usb_dev_ep_type_t type)</div><div class="ttdoc">Configure an endpoint.</div></div>
</div><!-- fragment --> <table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="groups" name="groups"></a>
API Reference</h2></td></tr>
<tr class="memitem:group__group__hal__results__usbdev"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__results__usbdev.html">USB Device HAL Results</a></td></tr>
<tr class="memdesc:group__group__hal__results__usbdev"><td class="mdescLeft">&#160;</td><td class="mdescRight">USB Device specific return codes. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:group__group__hal__usb__dev__endpoint"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__usb__dev__endpoint.html">Endpoint</a></td></tr>
<tr class="memdesc:group__group__hal__usb__dev__endpoint"><td class="mdescLeft">&#160;</td><td class="mdescRight">APIs relating to endpoint management. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:group__group__hal__usb__dev__common"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__usb__dev__common.html">Common</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:group__group__hal__usb__dev__ep0"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__usb__dev__ep0.html">EP0</a></td></tr>
<tr class="memdesc:group__group__hal__usb__dev__ep0"><td class="mdescLeft">&#160;</td><td class="mdescRight">APIs relating specifically to management of endpoint zero. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part
<div id="nav-path" class="navpath">
    <ul>
        <li class="footer">
            Generated for <b>Hardware Abstraction Layer (HAL)</b> by <b>Cypress Semiconductor Corporation</b>.
            All rights reserved.
        </li>
    </ul>
</div>
-->
</body>
</html>
